<html>
<head><meta charset="utf-8"><title>fallback for `Err` · t-lang/project-never-type · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/index.html">t-lang/project-never-type</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html">fallback for `Err`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218466704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/259160-t-lang/project-never-type/topic/fallback%20for%20%60Err%60/near/218466704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html#218466704">(Dec 01 2020 at 19:04)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="125270">@scottmcm</span> -- I was thinking that, conceivably, we could expand the fallback rules so that if you named an enum variant (e.g., <code>let x = Err(22)</code>), the type variables that are not named in that variant were considered to be "targets of a never coercion" (i.e., candidates to fallback to <code>!</code>). This would make <code>Err(22)?</code> work and fallback to <code>Result&lt;!, i32&gt;</code> as the final type. It would also make <code>let x = Err(22)</code> have the same type, for better or worse. Would be worth an experiment.</p>



<a name="218466743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/259160-t-lang/project-never-type/topic/fallback%20for%20%60Err%60/near/218466743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html#218466743">(Dec 01 2020 at 19:04)</a>:</h4>
<p>My main goal in deprecating the <code>()</code> fallback case is that I want the fallback (or lack thereof) for unbound type variables in <code>E</code> and <code>E?</code> to be the same</p>



<a name="218466780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/259160-t-lang/project-never-type/topic/fallback%20for%20%60Err%60/near/218466780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html#218466780">(Dec 01 2020 at 19:04)</a>:</h4>
<p>so I think that if we think <code>Err(22)</code> ought to fallback to <code>Result&lt;!, i32&gt;</code>, it should probably do so uniformly</p>



<a name="218478827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/259160-t-lang/project-never-type/topic/fallback%20for%20%60Err%60/near/218478827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html#218478827">(Dec 01 2020 at 20:45)</a>:</h4>
<p>Oh, interesting.  That seems logical to me.</p>



<a name="218510344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/259160-t-lang/project-never-type/topic/fallback%20for%20%60Err%60/near/218510344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html#218510344">(Dec 02 2020 at 03:04)</a>:</h4>
<p>Would this code continue to create a <code>Result&lt;bool, i32&gt;</code>?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Err</span><span class="p">(</span><span class="mi">22</span><span class="p">);</span><span class="w"></span>
<span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Ok</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="218516842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/259160-t-lang/project-never-type/topic/fallback%20for%20%60Err%60/near/218516842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html#218516842">(Dec 02 2020 at 05:26)</a>:</h4>
<p>Yes, because that bounds both of the type variables in the result type.  So there's no opportunity for it to fallback.</p>



<a name="218567834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/259160-t-lang/project-never-type/topic/fallback%20for%20%60Err%60/near/218567834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html#218567834">(Dec 02 2020 at 14:59)</a>:</h4>
<p>yep, what <span class="user-mention" data-user-id="125270">@scottmcm</span> said</p>



<a name="223177972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/259160-t-lang/project-never-type/topic/fallback%20for%20%60Err%60/near/223177972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/259160-t-lang/project-never-type/topic/fallback.20for.20.60Err.60.html#223177972">(Jan 19 2021 at 01:10)</a>:</h4>
<p>I think <code>Err(22)</code> becoming <code>Result&lt;!, i32&gt;</code> would generally be nice, because currently if you try to do this you'll get errors because the <code>Ok</code> branch has an unknown type, which is less than ideal for code which only ever produces <code>Err</code> anyways.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>